package com.itheima.lambda;

import java.util.Arrays;

public class LambdaDemo3 {
    public static void main(String[] args) {
        GirlFriend[] gf = new GirlFriend[3];
        GirlFriend gf1 = new GirlFriend("qq", 19, 168);
        GirlFriend gf2 = new GirlFriend("ww", 20, 170);
        GirlFriend gf3 = new GirlFriend("ee", 19, 169);
        gf[0] = gf1;
        gf[1] = gf2;
        gf[2] = gf3;

        Arrays.sort(gf,(o1,o2)->{
                double temp = o1.getAge() - o2.getAge();
                temp = temp == 0 ? o1.getHeight() - o2.getHeight() : temp;
                temp = temp == 0 ? o1.getName().compareTo(o2.getName()) : temp;

               if (temp > 0) {
                    return 1;
                } else if (temp < 0) {
                    return -1;
                }else {
                   return 0;
               }
            }
        );

        System.out.println(Arrays.toString(gf));

    }
}
